using GTA;
using System.Speech.Synthesis;
using System.Windows.Forms;

namespace YourNameSpace
{
    public class SpeechSynthesis : Script
    {
        public SpeechSynthesis()
        {
            KeyDown += OnKeyDown;
        }

        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.L)
            {
                // if possible, change the Default Voice in Windows to one that sounds less robotic
                // will crash if your Windows Default doesn't match one below, which is female in this case

                SpeechSynthesizer synth = new SpeechSynthesizer();
                synth.Volume = 100;
                synth.SetOutputToDefaultAudioDevice();
                synth.SelectVoiceByHints(VoiceGender.Female, VoiceAge.NotSet);

                string SpeechString =
                    "Hello User. You can use this for Help, as an example. From a menu or a keybind. " +
                    "You could explain how to use your script, which keybinds etc., " +
                    "This is a quick and dirty solution. A better solution is to use mp3 files, " +                    
                    "although they need to be added to your mod and placed in a folder.";

                synth.SpeakAsync(SpeechString);
            }
        }
    }
}